<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            border: 1px solid red;
        }
        .fa{
          width: 300px;  
        }
        .child{
            width: 100px;  
        }
    </style>
</head>
<body>
    <div class="fa">
        father
        <div class="child">child</div>
    </div>

    <button onclick="remove()">删除孩子</button>
    <script>
      
        function remove(){
            alert()
            let childs  = document.getElementsByClassName("child");
            //1.通过父节点移除元素对象
            // childs[0].parentNode.removeChild(childs[0])
            //2.主动移除
            // childs[0].remove();
            // console.log();

            let img1 = document.createElement("img");
            img1.setAttribute("src",'../img/快乐加倍.png');
            childs[0].parentNode.replaceChild(img1,childs[0])

        }
      
    </script>
</body>
</html>